<link href="${rc.getContextPath()}/manage/js/businessJs/my_webuploader.css" rel="stylesheet" type="text/css" />
<style>
.lookupEquipment span.error{
    position:absolute     !important;

    left:257px;
}
.imgremove{
	float: left;
}
.imgremove a{
	bottom: 2px;
	position: absolute;
	padding-left: 10px;
	text-decoration:underline;color:#289be5;line-height:25px;
}
</style>
<form method="post" id="Equipment" action="${rc.getContextPath()}/manage/equipment/saveEquipment" class="pageForm required-validate" 
enctype="multipart/form-data" onsubmit="return iframeCallback(this,dialogAjaxDone);">
    <div class="pageContent">
    <div class="pageFormContent" style="overflow-x:hidden;">
            <input type="hidden" name="navTabId" value="${navTabId!''}">
            <input type="hidden" name="id"
                value="<#if (equipment.equipmentCode)??>${equipment.equipmentCode!''}</#if>">
        <fieldset>
        <dl style="height:80px;">
        	<dt><label><@label key='equipmentImage.C,colon'>设备图片：</@label></label></dt>
        	<dd><div class="upload-wrap" style="float: left;">
					<div class="thumbnail">
						<#if equipment?? && equipment.pictureAttachmentCode??>	
						<img src="${rc.getContextPath()}/manage/common/showAttachement?attachmentCode=${equipment.pictureAttachmentCode!''}" height="80" width="80">
						</#if>						
					</div>
					<input type="file" name="pictureAttachment" accept="image/*">
				</div>
				<div class="imgremove" ><a href="#" onclick="_removeEquipmentImage()">移除</a></div>
				<input type="hidden" name="pictureAttachmentCode" value="${equipment.pictureAttachmentCode!''}">
			</dd>
		</dl>
        <dl>
            <dt><@label key='equipmentCode.C,colon'>设备编号：</@label></dt>
            <dd style="nowrap"><input type="text" name="equipmentCode"  size="22" type="text" maxlength="20" class="required  alphanumeric toUp" warn="<@label key='equipmentCode.C,alreadyExists'>设备编号已存在</@label>"
                              value="${equipment.equipmentCode!''}"
                              <#if pattern!="add">
                              readonly="readonly"
                              <#else>
                              remote="${rc.getContextPath()}/manage/equipment/validateEquipmentCode"
                             </#if>
                        />
            </dd>
        </dl>
        
        <dl>
            <dt><@label key='equipmentText.C,colon'>设备描述：</@label></dt>
            <dd><input size="22" <#if pattern!="add">readonly="readonly"</#if> type="text" maxlength="60" name="equipmentText" value="${equipment.equipmentText!''}" class="required" />
            </dd>
        </dl>  
        <dl>
            <dt><@label key="workUnitCode.C,colon">作业单元编号</@label></dt>
            <dd>
                <input class="look" id="operationComponentLookup.workUnitCode" value="${equipment.workUnitCode!''}"
                name="workUnitCode" type="text" postField="workUnitCode" 
                suggestFields="workUnitCode,workUnitText"  suggestUrl="${rc.getContextPath()}/manage/workUnit/workUnitSuggest" lookupGroup="operationComponentLookup"
                remote="${rc.getContextPath()}/manage/workUnit/chckWorkUnitCode" warn="<@label key='unitNotExist.M'>作业单元不存在！</@label>"/>
                <a class="btnLook" href="${rc.getContextPath()}/manage/workUnit/workUnitLookUp?lookupType=radio"  rel="operationComponentl_dialog" title="<@label key='select.C,workUnitCode.C'>选择作业单元</@label>" lookupGroup="operationComponentLookup" ></a>                                                          
            </dd>
        </dl>      
        <dl>
            <dt><@label key='equipmentCategory.C,colon'>设备类别：</@label></dt>
            <dd class="lookupEquipment">
                <input class="required look" id="categoryLookup.categoryCode" name="categoryCode" value="${equipment.categoryCode!''}" type="text" postField="categoryCode" suggestFields="categoryCode,categoryText" 
                suggestUrl="${rc.getContextPath()}/manage/emCategory/categoryDropdown" lookupGroup="categoryLookup" 
                    remote="${rc.getContextPath()}/manage/emCategory/checkCategoryCode" warn="<@label key='equipmentCategory.C,doesNotExist.C'>设备类别编号不存在</@label>"/>
                <a  class="btnLook" href="${rc.getContextPath()}/manage/emCategory/categoryLookup" width="700" height="300" rel="categoryLookup_dialog"  lookupGroup="categoryLookup" title="<@label key='queryEquipmentCategory.D'>设备类别选择<</@label>" ></a>
            </dd>
        </dl>
        <dl>
            <dt><@label key='equipmentStatus.C,colon'>设备状态：</@label></dt>
            <dd class="lookupEquipment">
                <input class="required look" id="statusLookup.statusCode" name="statusCode" value="${equipment.statusCode!''}" type="text" postField="statusCode" suggestFields="statusCode,statusText" 
                suggestUrl="${rc.getContextPath()}/manage/equipmentStatus/statusDropdown" lookupGroup="statusLookup"
                    remote="${rc.getContextPath()}/manage/equipmentStatus/checkEquipmentStatusCode" warn="<@label key='equipmentStatus.C,doesNotExist.C'>设备状态编号不存在</@label>"/>
                <a class="btnLook" href="${rc.getContextPath()}/manage/equipmentStatus/statusLookup" width="700" height="300"  rel="statusLookup_dialog"  lookupGroup="statusLookup" title="<@label key='queryEquipmentStatus.D'>设备状态选择</@label>"></a>
            </dd>
        </dl>
        <dl>
            <dt><@label key='specModel.C,colon'>规格型号：</@label></dt>
            <dd><input  name="specModel" value="${equipment.specModel!''}" maxlength="60" type="text" class="required" />
            </dd>
        </dl>
        <dl>
            <dt><@label key='purpose.C,colon'>设备用途</@label></dt>
            <dd><input name="purpose" value="${equipment.purpose!''}" maxlength="60" type="text" class="required" />
            </dd>
        </dl>
        <dl>
            <dt><@label key='location.C,colon'>设备位置：</@label></dt>
            <dd><input name="location"  value="${equipment.location!''}" maxlength="60" type="text" class="required"/>
            </dd>
        </dl>
        <dl>
            <dt><@label key='manufacturer.C,colon'>生产厂家：</@label></dt>
            <dd><input name="manufacturer"  value="${equipment.manufacturer!''}" maxlength="60" type="text" class="required"/>
            </dd>
        </dl>
        <dl>
            <dt><@label key='usageYears.C,colon'>使用年限：</@label></dt>
            <dd><input name="usageYears"  value="${equipment.usageYears!''}" maxlength="9" type="text" class="required digits" min="0"/>
            </dd>
        </dl>
        <dl>
            <dt><@label key='purchaseDate.C,colon'>购入日期：</@label></dt>
            <dd class="lookupEquipment"><input type="text" name="purchaseDate" value="${(equipment.purchaseDate?string('yyyy-MM-dd'))?if_exists}" class="required date"  dateFmt="yyyy-MM-dd"/>
                <a class="inputDateButton" href="javascript:;">选择</a>
            </dd>
        </dl>
        <dl>
            <dt><@label key='useDepartment.C,colon'>使用部门：</@label></dt>
            <dd><input name="useDepartment" value="${equipment.useDepartment!''}" maxlength="60" type="text" />
            </dd>
        </dl>
        <dl>
            <dt><@label key='assetCode.C,colon'>固定资产编号：</@label></dt>
            <dd><input type="text" name="assetCode" value="${equipment.assetCode!''}" maxlength="60" class="alphanumeric toUp" /></dd>
        </dl>
        <dl>
            <dt><@label key='assetValue.C,colon'>资产值：</@label></dt>
            <dd><input type="text" name="assetValue" maxlength="60" value="${equipment.assetValue!''}" /></dd>
        </dl>
        <dl>
            <dt><@label key='assetLevel.C,colon'>资产等级：</@label></dt>
            <dd><input type="text" named"assetLevel" maxlength="60" value="${equipment.assetLevel!''}" /></dd>
        </dl>
        
        <dl style="width:600px;height:50px;">
            <dt><@label key='memo.C,colon'>备注：</@label></dt>
            <dd>
                <textarea style="width:435px;height:50px" name="memo"  maxlength="200" value="${equipment.memo!''}" rows="4"><#if (equipment.memo)??>${equipment.memo!''}</#if></textarea>
            </dd>
        </dl>
        <dl>
            <dt>&nbsp;</dt>
            <dd>
                <label><input type="checkbox" name="lockFlag" value="1"
                    <#if
                    (equipment.lockFlag)?? && (equipment.lockFlag == 1)>
                    checked="true"</#if>><@label key="lock.C">锁定</@label></label>
            </dd>
        </dl>
        <dl style="height:140px;border:1px solid #d9dfe5;"class="nowrap">
                <div class="pageHeader">
                    <div id="uploader" class="wu-example">
                        <!--用来存放文件信息-->
                        <div id="filelist" class="uploader-list"></div>
                    </div>
                    <div id="equipmentFile" class="choose-file" uploaderOption="{
                                    server:'${rc.getContextPath()}/manage/equipment/saveEquipmentAttachment',
                                    fileVal:'equipmentFile',
                                    fileBnt: 'fileBnt',
                                    fileList: 'filelist',
                                    beforeFileQueuedMsg: '<@label key='exeBat_type_msg.D'>请不要上传exe，bat，sh等可执行的文件</@label>',
                                    uploadSuccess: _addEquipmentAttachment
                                }"><@label key='chooseFile.C'>选择文件</@label></div>
                    <div class="buttonActive" style="float: right;">
                        <div class="buttonContent"><button id="fileBnt" type="button"><@label key='upload.B'>上传</@label></button></div>
                    </div>
                </div>
                <table class="table canopration border" style="width: 100%;" id="equipmentAttachMentTable">
                    <thead>
                        <tr>
                            <th width="100"><@label key='fileName.C'>文件名称</@label></th>
                            <th width="100"><@label key='fileSize.C'>文件大小(bytes)</@label></th>
                            <th width="50"><@label key="opera.C">操作</@label></th>
                        </tr>
                    </thead>
                    <tbody>
                        <#if equipmentAttachList?? && (equipmentAttachList?size gt 0)>
                            <#list equipmentAttachList as equipmentAttach>
                            <tr id="${equipmentAttach_index}">
                                <td>${equipmentAttach.fileName!''}<input type='hidden' name='equipmentAttachList[${equipmentAttach_index}].fileName' value="${equipmentAttach.fileName!''}"/></td>
                                <td>${((equipmentAttach.fileSize)/1024)?ceiling}KB<input type='hidden' name='equipmentAttachList[${equipmentAttach_index}].attachmentCode' value="${equipmentAttach.attachmentCode!''}"/></td>
                                <td>
                                    <a title="<@label key='delete.B'>删除</@label>" target='ajax' class='btnDel' onclick='_delEquipmentAttachment(${equipmentAttach_index});'></a>
                                    <a title="<@label key='download.B'>下载</@label>" target='dwzExport' class='btnAttach' href="${rc.getContextPath()}/manage/common/downloadAttachement?attachmentCode=${equipmentAttach.attachmentCode!''}&fileName=${equipmentAttach.fileName!''}"></a>
                                </td>
                            </tr>
                            </#list>
                        </#if>
                    </tbody>
                </table>
            </dl>
        </fieldset>
    </div>
    <#if equipment??>
        <#assign createInfo=equipment>
        <#include "/common/createInfo.html">
    </#if> 
    <div class="formBar">
        <ul>
            <li><div class="buttonActive"><div class="buttonContent"><button type="submit">保存</button></div></div></li>
            <li>
                <div class="buttonActiveGrey"><div class="buttonContent"><button type="button" class="close">取消</button></div></div>
            </li>
        </ul>
    </div>
    </div>
</form>


<script>
var equipmentAttachmentCount = -1;
<#if equipmentAttachList?? && equipmentAttachList?size gt 0>
    equipmentAttachmentCount = ${equipmentAttachList?size}-1;        
</#if>
var $currentDialog = $.pdialog.getCurrent();
var $equipmentAttachMentTable=$("#equipmentAttachMentTable", $currentDialog);

function _addEquipmentAttachment(data) {
    if(!data)
        return;
    equipmentAttachmentCount ++ ;
    var gridTheadTh = $("#equipmentAttachMentTable", $currentDialog).find("table thead th");
    var _id=equipmentAttachmentCount;
    var tr = "<tr id="+_id+">";
    tr += "<td style='width:"+$(gridTheadTh[0]).width()+"px'><div>"+data.fileName+"</div><input type='hidden' name='equipmentAttachList["+_id+"].fileName' value='"+data.fileName+"'/></td>";
    tr += "<td style='width:"+$(gridTheadTh[1]).width()+"px'><div>"+Math.ceil(data.fileSize/1024)+"KB</div><input type='hidden' name='equipmentAttachList["+_id+"].attachmentCode' value='"+data.attachmentCode+"'/></td>";
    tr += "<td style='width:"+$(gridTheadTh[2]).width()+"px'><a title='<@label key='delete.B'>删除</@label>' target='ajax' class='btnDel' onclick='_delEquipmentAttachment("+_id+");'><@label key='delete.B'>删除</@label></a>";
    tr += "<a title='<@label key='download.B'>下载</@label>' target='dwzExport' class='btnAttach' href='${rc.getContextPath()}/manage/common/downloadAttachement?attachmentCode="+data.attachmentCode+"&fileName="+data.fileName+"'></a></td>"
    tr += "</tr>";
    $("#equipmentAttachMentTable .gridTbody", $currentDialog).find("table tbody").append(tr);
}

function _delEquipmentAttachment(_id) {
    $("tr#"+_id,$currentDialog).remove();
}

function _removeEquipmentImage() {
    $(".thumbnail img", $currentDialog).remove();
    $("input[name='pictureAttachmentCode']",$currentDialog).val("");
    $("input[name='pictureAttachment']", $currentDialog).val(""); 
}

</script>
<script type="text/javascript" src="${rc.getContextPath()}/manage/js/businessJs/my_webuploader.js"></script>
